/*
 * Copyright 2002-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.expression;

/**
 * 提供给表达式分析器的输入，它可能影响表达式分析/编译例程。
 * 它会对我们解析表达式字符串的行为影响
 *
 * @author Keith Donald
 * @author Andy Clement
 * @since 3.0
 */
public interface ParserContext {

	/**
	 * 是否是模版表达式。  比如：#{3 + 4}
	 */
	boolean isTemplate( );

	/**
	 * 模版的前缀、后缀  子类是可以定制化的~~~. 例如:前缀 "${", 后缀 "}"
	 */
	String getExpressionPrefix( );

	/**
	 * 模版的前缀、后缀  子类是可以定制化的~~~. 例如:前缀 "${", 后缀 "}"
	 */
	String getExpressionSuffix( );


	/**
	 *默认提供的实例支持：#{} 的形式   显然我们可以改变它但我们一般并不需要这么去做~
	 *
	 * @see #isTemplate()
	 */
	ParserContext TEMPLATE_EXPRESSION = new ParserContext() {

		@Override
		public boolean isTemplate( ) {
			return true;
		}

		@Override
		public String getExpressionPrefix( ) {
			return "#{";
		}

		@Override
		public String getExpressionSuffix( ) {
			return "}";
		}
	};

}
